﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Wantn.FIS.Enum
@{
    ViewBag.Title = "选择物料";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool">
    <input id="txtQuery" type="text" class="searchText" placeholder="可根据物料名称、备注查询"/>
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
<table id="List"></table>

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">
        $('#List').datagrid({
            url: '@Url.Action("GetListNotINSupplierId")?SuppID=@ViewBag.SuppID',
            width:SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'MATERIEL_ID',
            sortOrder: 'desc',
            idField: 'MATERIEL_ID',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: false,//单选模式
            rownumbers: true,//行号
            onLoadSuccess: function(data) {                @foreach(var r in perm){ if (r.Category == 2) { @Html.Raw("$(this).datagrid('hideColumn','" + r.KeyCode + "'); "); } }
            },
            columns: [[
                { field: 'MATERIEL_ID', title: '物料编号', width: 80,checkbox : true},
                { field: 'MATERIEL_NAME', title: '物料名称', width: 80,sortable:true },
                { field: 'MATERIEL_TYPE_ID', title: '物料类型', width: 80, sortable: true, hidden: true },
                { field: 'MATERIEL_TYPEName', title: '物料类型', width: 80, sortable: true,hidden:true },
                { field: 'STATISTICS', title: '统计类型', width: 80, sortable: true, formatter:@Html.Raw(EnumMvcHelper.GridFormatterFunc<MetStatisticsType>())},
                //{ field: 'KKSCODE', title: 'KKS编码', width: 80,sortable:true,hidden:true },
                { field: 'REMARKS', title: '备注', width: 80,sortable:true },
                { field: 'TemplateName', title: '流程模板', width: 80,sortable:true }
            ]]
        });
    
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnReturn").click(function () {
            var data = $("#List").datagrid("getChecked");
            window.parent.SetSelectValue(data);
            window.parent.frameReturnByClose();
        });
    });
    $("#btnQuery").click(function () {
       
            var queryStr = $("#txtQuery").val();
            if (queryStr == null) {
                queryStr = "%";
            }
            $("#List").datagrid("load", { queryStr: queryStr,SuppID:"@ViewBag.SuppID" });
       

    });
    function resizeLayout()
     {
         setTimeout(function () {
             $('#List').datagrid('resize', {
             }).datagrid('resize', {
                 width: $(window).width() - 450,
                 height: SetGridHeightSub(45)
             });
         },100);
	    }
</script>

